using System;
using System.Collections.Generic;
using System.Text;
using Atom.Core;

namespace MTVMusicPlugin
{
  public class VideoEntry
  {
    private AtomEntry entry;

    public AtomEntry Entry
    {
      get { return entry; }
      set { entry = value; }
    }

    public string PlayblackUrl
    {
      get
      {
        try
        {
          return Entry.Media["content"][0].Attributes["url"];
        }
        catch
        {
        }
        try
        {
          string s = Entry.Media["player"][0].Attributes["url"];
          return string.Format("http://media.mtvnservices.com/mgid:uma:video:api.mtvnservices.com:{0}", s.Substring(s.IndexOf("=") + 1));
        }
        catch 
        {
          
        }

        return string.Empty;
      }
    }

    public string ArtistUrl
    {
      get
      {
        string s = "";
        foreach (AtomLink al in Entry.Links)
        {
          if (al.HRef.ToString().Contains("/artist/") && !al.HRef.ToString().Contains("related"))
            return al.HRef.ToString();
        }
        return s;
      }
    }

    public string GenreUrl
    {
      get
      {
        string s = "";
        foreach (AtomLink al in Entry.Links)
        {
          if (al.HRef.ToString().Contains("/genre") && !al.HRef.ToString().Contains("related"))
            return al.HRef.ToString();
        }
        return s;
      }
    }

    public string Genre
    {
      get
      {
        string s = "";
        foreach (AtomLink al in Entry.Links)
        {
          if (al.HRef.ToString().Contains("/genre") && !al.HRef.ToString().Contains("related"))
            return al.Title;
        }
        return s;
      }
    }

    public VideoEntry()
    {
      Entry = new AtomEntry();
    }

    public VideoEntry(AtomEntry ae)
    {
      Entry = ae;
    }

  }
}
